from django.http import HttpResponse
from django.template import loader

def index(request):
    """
    首页视图函数
    """
    html = """
    <!DOCTYPE html>
    <html>
    <head>
        <title>Fresh Chain Supply System API</title>
        <style>
            body {
                font-family: Arial, sans-serif;
                line-height: 1.6;
                max-width: 800px;
                margin: 0 auto;
                padding: 20px;
            }
            h1 {
                color: #4CAF50;
                border-bottom: 2px solid #4CAF50;
                padding-bottom: 10px;
            }
            .links {
                margin-top: 20px;
            }
            .links a {
                display: block;
                margin: 10px 0;
                color: #2196F3;
                text-decoration: none;
                font-weight: bold;
            }
            .links a:hover {
                text-decoration: underline;
            }
        </style>
    </head>
    <body>
        <h1>Fresh Chain Supply System API</h1>
        <p>Welcome to the Fresh Chain Supply System API. This is the backend service for the Fresh Chain application.</p>
        
        <div class="links">
            <h2>Available Documentation:</h2>
            <a href="/swagger/">Swagger API Documentation</a>
            <a href="/redoc/">ReDoc API Documentation</a>
            <a href="/admin/">Admin Interface</a>
        </div>
        
        <div class="links">
            <h2>Main API Endpoints:</h2>
            <a href="/api/products/">Products API</a>
            <a href="/api/users/">Users API</a>
            <a href="/api/sales-orders/">Sales Orders API</a>
            <a href="/api/delivery-tasks/">Delivery Tasks API</a>
        </div>
    </body>
    </html>
    """
    return HttpResponse(html) 